const router = require('koa-router')()
const svgCaptcha = require("svg-captcha")
const user = require('./user.json')
const jwt = require('jsonwebtoken');
const formidable = require("formidable")
const path = require("path")
const mime = require("mime-types")
const fs = require("fs");
const { Console } = require('console');
var verCode = ''



//About.vue


// 获取
router.get("/getnum", async (ctx, next) => {
  let num = []
  let sql = "select * from user1";
  let result = await ctx.db.EXCUTE(sql);
  // console.log(result)
  result.forEach(item => {
    num.push({
      userName: item.userName,
      telephoneNum: item.tel,
      eMail: item.eMail,
      site: item.site,
      timer: item.timer,
      chapterId: item.chapterId
    })
  })
  ctx.body = num;
})

// 查询
router.post("/select",async(ctx,next)=>{
  let text = ctx.request.body.text
  let sql = "select *  from user1 where userName Like '%" + text + "%'" 
  let result = await ctx.db.EXCUTE(sql);
  console.log(result)
  ctx.body = result
})




// Logistics.vue

// 获取
router.get("/getlognum", async (ctx, next) => {
  let logNum = []
  let sql = "select * from logistics ";
  let result = await ctx.db.EXCUTE(sql);
  // console.log(result)
  result.forEach(item => {
    console.log(item.userName)
    logNum.push({
      userName: item.userName,
      tel: item.tel,
      road: item.road,
      site: item.site,
      timer: item.timer,
      chapterId: item.chapterId
    })
  })
  ctx.body = logNum;
})
// 查询
router.post("/selectlog",async(ctx,next)=>{
  let text = ctx.request.body.text
  let sql = "select *  from logistics where userName Like '%" + text + "%'" 
  let result = await ctx.db.EXCUTE(sql);
  console.log(result)
  ctx.body = result
})
module.exports = router

// 置顶
router.post("/movetotop",async(ctx,next)=>{
  let chapterId = ctx.request.body.chapterId
  console.log(ctx.request.body.chapterId)
  let sql = "select *  from logistics1 order by chapterId='" + chapterId +"'DESC" 
  let result = await ctx.db.EXCUTE(sql);
  console.log(result)
  ctx.body=result
})
// 查询
router.post("/select",async(ctx,next)=>{
  let text = ctx.request.body.text
  let sql = "select *  from user where userName Like '%" + text + "%'" 
  let result = await ctx.db.EXCUTE(sql);
  console.log(result)
  ctx.body = result
})















// logistics1.vue

// 获取
router.get("/l1", async (ctx, next) => {
  let logNum = []
  let sql = "select * from logistics1 ";
  let result = await ctx.db.EXCUTE(sql);
  // console.log(result)
  result.forEach(item => {
    console.log(item.userName)
    logNum.push({
      userName: item.userName,
      tel: item.tel,
      road: item.road,
      site: item.site,
      timer: item.timer,
      chapterId: item.chapterId
    })
  })
  ctx.body = logNum;
})

router.post("/selectlog",async(ctx,next)=>{

  // console.log(1)
  // console.log(ctx.request.body)
  // ctx.body="1"
  let text = ctx.request.body.text
  let sql = "select *  from logistics1 where userName Like '%" + text + "%'" 
  let result = await ctx.db.EXCUTE(sql);
  console.log(result)
  ctx.body = result
})


// logistics2.vue

// 获取
router.get("/l2", async (ctx, next) => {
  let logNum = []
  let sql = "select * from logistics2 ";
  let result = await ctx.db.EXCUTE(sql);
  // console.log(result)
  result.forEach(item => {
    console.log(item.userName)
    logNum.push({
      userName: item.userName,
      tel: item.tel,
      road: item.road,
      site: item.site,
      timer: item.timer,
      chapterId: item.chapterId
    })
  })
  ctx.body = logNum;
})

router.post("/selectlog",async(ctx,next)=>{

  // console.log(1)
  // console.log(ctx.request.body)
  // ctx.body="1"
  let text = ctx.request.body.text
  let sql = "select *  from logistics1 where userName Like '%" + text + "%'" 
  let result = await ctx.db.EXCUTE(sql);
  console.log(result)
  ctx.body = result
})








//文本框提交
router.post("/selectlogs",async(ctx,next)=>{
  console.log(ctx.request.body)
 
  ctx.body="1"
})
module.exports = router


<template>
  <div id="big">
    <el-button type="primary" size="mini" @click="showDrawer" id="add">添加数据</el-button>
    <el-input style="width:20%" placeholder="输入路线查询" v-model="text" @input="searchh" id="select"></el-input>
    <el-button type="primary" size="mini" @click="select" id="renew2">查询</el-button>
    <el-button type="primary" size="mini" @click="renew">重置</el-button>
    <el-table
      :data="chapterList.slice((paginations.currentPage - 1) * paginations.PageSize, paginations.currentPage * paginations.PageSize)"
      style="width: 67%; margin: 0 auto;" id="main">
      <el-table-column label="派送线路">
        <template slot-scope="scope">
          
          <span>{{ scope.row.type }}</span>
        </template>
      </el-table-column>
      <el-table-column label="途径">
        <template slot-scope="scope">
          <span>
            {{ scope.row.road }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="地址">
        <template slot-scope="scope">
          <span>
            {{ scope.row.site }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="电话">
        <template slot-scope="scope">
          <span>
            {{ scope.row.tel }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="时间">
        <template slot-scope="scope">
          <span>
            {{ scope.row.timer }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="操作">

        <template slot-scope="scope">
          <el-button size="mini" @click="moveToTop(scope.$index, scope.row)">置顶</el-button>
          <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
          <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-drawer title="我是标题" :visible.sync="drawer" :with-header="false">
      <div style="width: 50%; margin:0 auto; margin-top: 50px">
        <el-input v-model="userName" placeholder="线路名称"></el-input>
      </div>
      <div style="width: 50%; margin:0 auto; margin-top: 50px">
        <el-input v-model="road" placeholder="途径"></el-input>
      </div>
      <div style="width: 50%; margin:0 auto; margin-top: 50px">
        <el-input v-model="site" placeholder="地址"></el-input>
      </div>
      <div style="width: 50%; margin:0 auto; margin-top: 50px">
        <el-input v-model="tel" placeholder="电话"></el-input>
      </div>
      <div style="width: 50%; margin:0 auto; margin-top: 50px">
        <el-date-picker v-model="timer" style="width:95%;" type="date" placeholder="选择日期">
        </el-date-picker>
      </div>
      <div style="margin-top: 30px">
        <el-button type="primary" size="mini" @click="subform" v-show="!this.chapterId">提交</el-button>
        <el-button type="primary" size="mini" @click="subEditForm" v-show="this.chapterId">保存</el-button>
      </div>
    </el-drawer>
    <div class="block">
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
        :current-page="paginations.currentPage" :page-sizes="paginations.pageSizes" :page-size="paginations.PageSize"
        layout="total, sizes, prev, pager, next, jumper" :total="chapterList.length">
      </el-pagination>
    </div>
  </div>
</template>
    
<script>
import axios from 'axios'
export default {
  data() {
    return {
      text: '',
      // searchResult: [],
      chapterList: [],
      drawer: false,
      chapterTitle: "",
      chapterId: "",
      userName: "",
      road: "",
      site: "",
      tel: "",
      timer: "",
      //分页
      paginations: {
        // 默认显示第几页
        currentPage: 1,
        // 个数选择器（可修改）
        pageSizes: [1, 2, 3, 4],
        // 默认每页显示的条数（可修改）
        PageSize: 4,
      },
    }
  },
  // created() {
  //   this.searchResult = this.chapterList //存储
  // },
  methods: {
    //  编辑的提交
    subEditForm() {
      if (localStorage.getItem('token')) {
        axios.post(
          "http://localhost:3000/xiugai",
          {
            
          }
        ).then((res) => {
          if (res.data.code == 200) {
            //success warn danger
            this.drawer = false;
            this.getList();
          }
        })
      } else {
        alert('未登录')
      }

    },
    // 添加数据的提交
    subform() {
      if (localStorage.getItem('token')) {
        axios.post(
          "http://localhost:3000/sublog",
          { userName: this.userName, timer: this.timer, road: this.road, site: this.site, tel: this.tel }
        ).then((res) => {
          if (res.data.code == 200) {
            this.drawer = false;
            this.getList();
          }
        })
      } else {
        alert('未登录')
      }
    },
    // 添加数据的默认内容
    showDrawer() {
      this.drawer = true;
      this.userName = "";
      this.site = "";
      this.tel = "";
      this.road = "";
      this.chapterId = "";
      this.timer = "";
    },
    // 编辑
    handleEdit(index, row) {
      this.drawer = true;
      this.chapterId = row.chapterId;
      this.timer = row.timer;
      this.userName = row.userName;
      this.road = row.road;
      this.site = row.site;
      this.tel = row.tel;
      console.log(row)
    },
    // 删除
    handleDelete(index, row) {
      let chapterId = row.chapterId;
      if (localStorage.getItem('token')) {
        axios.post(
          "http://localhost:3000/dellog",
          { chapterId: chapterId }
        ).then((res) => {
          if (res.data.code == 200) {
            this.chapterList.splice(index, 1);
          }
        })
      } else {
        alert('未登录')
      }
    },
    // 置顶
    moveToTop(index, row) {
      let chapterId = row.chapterId;
      axios.post("http://localhost:3000/movetotop", { chapterId: chapterId }).then(res => {
        let result = res.data;
        this.chapterList = result;
        this.searchResult = this.chapterList
      })
    },
    // 查询
    select() {
      axios.post("http://localhost:3000/selectlog", { text: this.text }).then(res => {
        console.log(res.data)
        let result = res.data;
        this.chapterList = result;
      })
    },
    // 重置
    renew() {
      axios.get("http://localhost:3000/getlognum").then(res => {

      })
    },
    getList() {
      axios.get("http://localhost:3000/getlognum").then(res => {
        let result = res.data;
        this.chapterList = result;
        // this.searchResult = this.chapterList
      })
    },

    // //分页/
    // 每页显示多少条
    handleSizeChange(val) {
      // 改变每页显示的条数 
      this.paginations.PageSize = val
      // 注意：在改变每页显示的条数时，要将页码显示到第一页
      this.paginations.currentPage = 1
      console.log(`每页 ${val} 条`);
    },
    // 现在显示当前页的第几页
    handleCurrentChange(val) {
      // 改变默认的页数
      this.paginations.currentPage = val
      console.log(`当前页: ${val}`);
    },
    // handleOpen(key, keyPath) {
    //   console.log(key, keyPath);
    // },
    // handleClose(key, keyPath) {
    //   console.log(key, keyPath);
    // }

    // searchh: function () {
    //   if (localStorage.getItem('token')) {
    //     this.searchResult = this.chapterList.filter(item => item.userName.includes(this.text))
    //   } else {
    //     alert('未登录')
    //   }
    // }
  },
  mounted() {
    console.log(this.$route)
    this.getList();
  }
}
</script>
<style>
#big {
  margin: 0 auto;
  height: 800px;
}

#add {
  margin-left: 260px;
}

#select {
  margin-left: 600px;
}

.block {
  margin-left: 400px
}
#renew2{
  margin-left: 150px;
}
</style>





<template>
  <div id="big">
    <el-button type="primary" size="mini" @click="showDrawer" id="add">添加数据</el-button>
    <el-input style="width:20%" placeholder="输入路线查询" v-model="text" @input="searchh" id="select"></el-input>
    <el-button type="primary" size="mini" @click="select" id="renew2">查询</el-button>
    <el-button type="primary" size="mini" @click="renew">重置</el-button>
    <el-table
      :data="chapterList.slice((paginations.currentPage - 1) * paginations.PageSize, paginations.currentPage * paginations.PageSize)"
      style="width: 67%; margin: 0 auto;" id="main">
      <el-table-column label="派送线路">
        <template slot-scope="scope">
          
          <span>{{ scope.row.type }}</span>
        </template>
      </el-table-column>
      <el-table-column label="途径">
        <template slot-scope="scope">
          <span>
            {{ scope.row.road }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="地址">
        <template slot-scope="scope">
          <span>
            {{ scope.row.site }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="电话">
        <template slot-scope="scope">
          <span>
            {{ scope.row.tel }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="时间">
        <template slot-scope="scope">
          <span>
            {{ scope.row.timer }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="操作">

        <template slot-scope="scope">
          <el-button size="mini" @click="moveToTop(scope.$index, scope.row)">置顶</el-button>
          <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
          <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-drawer title="我是标题" :visible.sync="drawer" :with-header="false">
      <div style="width: 50%; margin:0 auto; margin-top: 50px">
        <el-input v-model="userName" placeholder="线路名称"></el-input>
      </div>
      <div style="width: 50%; margin:0 auto; margin-top: 50px">
        <el-input v-model="road" placeholder="途径"></el-input>
      </div>
      <div style="width: 50%; margin:0 auto; margin-top: 50px">
        <el-input v-model="site" placeholder="地址"></el-input>
      </div>
      <div style="width: 50%; margin:0 auto; margin-top: 50px">
        <el-input v-model="tel" placeholder="电话"></el-input>
      </div>
      <div style="width: 50%; margin:0 auto; margin-top: 50px">
        <el-date-picker v-model="timer" style="width:95%;" type="date" placeholder="选择日期">
        </el-date-picker>
      </div>
      <div style="margin-top: 30px">
        <el-button type="primary" size="mini" @click="subform" v-show="!this.chapterId">提交</el-button>
        <el-button type="primary" size="mini" @click="subEditForm" v-show="this.chapterId">保存</el-button>
      </div>
    </el-drawer>
    <div class="block">
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
        :current-page="paginations.currentPage" :page-sizes="paginations.pageSizes" :page-size="paginations.PageSize"
        layout="total, sizes, prev, pager, next, jumper" :total="chapterList.length">
      </el-pagination>
    </div>
  </div>
</template>
    
<script>
import axios from 'axios'
export default {
  data() {
    return {
      text: '',
      // searchResult: [],
      chapterList: [],
      drawer: false,
      chapterTitle: "",
      chapterId: "",
      userName: "",
      road: "",
      site: "",
      tel: "",
      timer: "",
      //分页
      paginations: {
        // 默认显示第几页
        currentPage: 1,
        // 个数选择器（可修改）
        pageSizes: [1, 2, 3, 4],
        // 默认每页显示的条数（可修改）
        PageSize: 4,
      },
    }
  },
  // created() {
  //   this.searchResult = this.chapterList //存储
  // },
  methods: {
    //  编辑的提交
    subEditForm() {
      if (localStorage.getItem('token')) {
        axios.post(
          "http://localhost:3000/xiugai",
          {
            
          }
        ).then((res) => {
          if (res.data.code == 200) {
            //success warn danger
            this.drawer = false;
            this.getList();
          }
        })
      } else {
        alert('未登录')
      }

    },
    // 添加数据的提交
    subform() {
      if (localStorage.getItem('token')) {
        axios.post(
          "http://localhost:3000/sublog",
          { userName: this.userName, timer: this.timer, road: this.road, site: this.site, tel: this.tel }
        ).then((res) => {
          if (res.data.code == 200) {
            this.drawer = false;
            this.getList();
          }
        })
      } else {
        alert('未登录')
      }
    },
    // 添加数据的默认内容
    showDrawer() {
      this.drawer = true;
      this.userName = "";
      this.site = "";
      this.tel = "";
      this.road = "";
      this.chapterId = "";
      this.timer = "";
    },
    // 编辑
    handleEdit(index, row) {
      this.drawer = true;
      this.chapterId = row.chapterId;
      this.timer = row.timer;
      this.userName = row.userName;
      this.road = row.road;
      this.site = row.site;
      this.tel = row.tel;
      console.log(row)
    },
    // 删除
    handleDelete(index, row) {
      let chapterId = row.chapterId;
      if (localStorage.getItem('token')) {
        axios.post(
          "http://localhost:3000/dellog",
          { chapterId: chapterId }
        ).then((res) => {
          if (res.data.code == 200) {
            this.chapterList.splice(index, 1);
          }
        })
      } else {
        alert('未登录')
      }
    },
    // 置顶
    moveToTop(index, row) {
      let chapterId = row.chapterId;
      axios.post("http://localhost:3000/movetotop", { chapterId: chapterId }).then(res => {
        let result = res.data;
        this.chapterList = result;
        this.searchResult = this.chapterList
      })
    },
    // 查询
    select() {
      axios.post("http://localhost:3000/selectlog", { text: this.text }).then(res => {
        console.log(res.data)
        let result = res.data;
        this.chapterList = result;
      })
    },
    // 重置
    renew() {
      axios.get("http://localhost:3000/getlognum").then(res => {

      })
    },
    getList() {
      axios.get("http://localhost:3000/getlognum").then(res => {
        let result = res.data;
        this.chapterList = result;
        // this.searchResult = this.chapterList
      })
    },

    // //分页/
    // 每页显示多少条
    handleSizeChange(val) {
      // 改变每页显示的条数 
      this.paginations.PageSize = val
      // 注意：在改变每页显示的条数时，要将页码显示到第一页
      this.paginations.currentPage = 1
      console.log(`每页 ${val} 条`);
    },
    // 现在显示当前页的第几页
    handleCurrentChange(val) {
      // 改变默认的页数
      this.paginations.currentPage = val
      console.log(`当前页: ${val}`);
    },
    // handleOpen(key, keyPath) {
    //   console.log(key, keyPath);
    // },
    // handleClose(key, keyPath) {
    //   console.log(key, keyPath);
    // }

    // searchh: function () {
    //   if (localStorage.getItem('token')) {
    //     this.searchResult = this.chapterList.filter(item => item.userName.includes(this.text))
    //   } else {
    //     alert('未登录')
    //   }
    // }
  },
  mounted() {
    console.log(this.$route)
    this.getList();
  }
}
</script>
<style>
#big {
  margin: 0 auto;
  height: 800px;
}

#add {
  margin-left: 260px;
}

#select {
  margin-left: 600px;
}

.block {
  margin-left: 400px
}
#renew2{
  margin-left: 150px;
}
</style>






<template>
  <div id="big">
    <el-button type="primary" size="mini" @click="showDrawer" id="add1">添加数据</el-button>
    <el-input style="width:20%" placeholder="输入用户名查询" v-model="text" id="select1"></el-input>
    <el-button type="primary" size="mini" @click="select" id="renew">查询</el-button>
    <el-button type="primary" size="mini" @click="renew" >重置</el-button>
    <el-table
      :data="chapterList.slice((paginations.currentPage - 1) * paginations.PageSize, paginations.currentPage * paginations.PageSize)"
      style="width: 60%; margin: 0 auto;" id="main">
      <el-table-column label="姓名">
        <template slot-scope="scope">
          <i class="el-icon-time"></i>
          <span style="margin-left: 10px">{{ scope.row.userName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="电话">
        <template slot-scope="scope">
          <span>
            {{ scope.row.telephoneNum }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="邮箱">
        <template slot-scope="scope">
          <span>
            {{ scope.row.eMail }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="地址">
        <template slot-scope="scope">
          <span>
            {{ scope.row.site }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
          <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-drawer title="我是标题" :visible.sync="drawer" :with-header="false">
      <div style="width: 50%; margin:0 auto; margin-top: 50px">
        <el-input v-model="userName" placeholder="姓名"></el-input>
      </div>
      <div style="width: 50%; margin:0 auto; margin-top: 50px">
        <el-input v-model="telephoneNum" placeholder="电话"></el-input>
      </div>
      <div style="width: 50%; margin:0 auto; margin-top: 50px">
        <el-input v-model="eMail" placeholder="邮箱"></el-input>
      </div>
      <div style="width: 50%; margin:0 auto; margin-top: 50px">
        <el-input v-model="site" placeholder="地址"></el-input>
      </div>
      <div style="width: 50%; margin:0 auto; margin-top: 50px">
        <el-date-picker v-model="timer" style="width:95%;" type="date" placeholder="选择日期">
        </el-date-picker>
      </div>
      <div style="margin-top: 30px">
        <el-button type="primary" size="mini" @click="subform" v-show="!this.chapterId">提交</el-button>
        <el-button type="primary" size="mini" @click="subEditForm" v-show="this.chapterId">保存</el-button>
      </div>
    </el-drawer>
    <div class="block">
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
        :current-page="paginations.currentPage" :page-sizes="paginations.pageSizes" :page-size="paginations.PageSize"
        layout="total, sizes, prev, pager, next, jumper" :total="chapterList.length">
      </el-pagination>
    </div>
  </div>
</template>
  
<script>
import axios from 'axios'
export default {
  data() {
    return {
      text: '',
      // searchResult: [],
      chapterList: [],
      drawer: false,
      chapterTitle: "",
      chapterId: "",
      userName: "",
      telephoneNum: "",
      eMail: "",
      site: "",
      timer: "",
      //分页
      paginations: {
        // 默认显示第几页
        currentPage: 1,
        // 个数选择器（可修改）
        pageSizes: [1, 2, 3, 4],
        // 默认每页显示的条数（可修改）
        PageSize: 4,
      },
    }
  },
  // watch:{
  //   'text':(newV,oldV)=>{
  //     if(newV == ''){
  //       axios.get("http://localhost:3000/getnum").then(res => {
  //       let result = res.data;
  //       console.log(result)
  //       // this.chapterList = result;
  //       // this.searchResult = this.chapterList
  //     })
  //     }
  //   }
  // },
  // created() {
  //   this.searchResult = this.chapterList //存储
  // },
  methods: {
    //  编辑的提交
    subEditForm() {
      if (localStorage.getItem('token')) {
        axios.post(
          "http://localhost:3000/subeditform",
          {
            chapterId: this.chapterId,
            userName: this.userName,
            telephoneNum: this.telephoneNum,
            eMail: this.eMail,
            site: this.site,
            timer: this.timer
          }
        ).then((res) => {
          if (res.data.code == 200) {
            //success warn danger
            this.drawer = false;
            this.getList();
          }
        })
      } else {
        alert('未登录')
      }
    },
    // 添加数据的提交
    subform() {
      if (localStorage.getItem('token')) {
        axios.post(
          "http://localhost:3000/subform",
          { userName: this.userName, timer: this.timer, telephoneNum: this.telephoneNum, eMail: this.eMail, site: this.site }
        ).then((res) => {
          if (res.data.code == 200) {
            this.drawer = false;
            this.getList();
          }
        })
      } else {
        alert('未登录')
      }
    },
    // 添加数据的默认内容
    showDrawer() {
      this.drawer = true;
      this.userName = "";
      this.eMail = "";
      this.site = "";
      this.telephoneNum = "";
      this.chapterId = "";
      this.timer = "";
    },
    // 编辑
    handleEdit(index, row) {
      this.drawer = true;
      this.chapterId = row.chapterId;
      this.timer = row.timer;
      this.userName = row.userName;
      this.telephoneNum = row.telephoneNum;
      this.eMail = row.eMail;
      this.site = row.site;
      console.log(row)
    },
    // 删除
    handleDelete(index, row) {
      let chapterId = row.chapterId;
      if (localStorage.getItem('token')) {
        axios.post(
          "http://localhost:3000/delchapter",
          { chapterId: chapterId }
        ).then((res) => {
          if (res.data.code == 200) {
            this.getList();
          }
        })
      } else {
        alert('未登录')
      }
    },
    // 查询
    select() {
      axios.post("http://localhost:3000/select", { text: this.text }).then(res => {
        console.log(res.data)
        let result = res.data;
        this.chapterList = result;
      })
    },
    // 重置
    renew(){
      axios.get("http://localhost:3000/getnum").then(res => {
        let result = res.data;
        this.chapterList = result;
        this.text = ''
      })
    },
    //获取
    getList() {
      axios.get("http://localhost:3000/getnum").then(res => {
        let result = res.data;
        this.chapterList = result;
        // this.searchResult = this.chapterList
      })
    },
    // //分页/
    // 每页显示多少条
    handleSizeChange(val) {
      // 改变每页显示的条数 
      this.paginations.PageSize = val
      // 注意：在改变每页显示的条数时，要将页码显示到第一页
      this.paginations.currentPage = 1
      console.log(`每页 ${val} 条`);
    },
    // 现在显示当前页的第几页
    handleCurrentChange(val) {
      // 改变默认的页数
      this.paginations.currentPage = val
      console.log(`当前页: ${val}`);
    },
    // handleOpen(key, keyPath) {
    //   console.log(key, keyPath);
    // },
    // handleClose(key, keyPath) {
    //   console.log(key, keyPath);
    // }

    // searchh: function () {
    //   if (localStorage.getItem('token')) {
    //     this.searchResult = this.chapterList.filter(item => item.userName.includes(this.text))
    //   } else {
    //     alert('未登录')
    //   }
    // }
  },
  mounted() {
    console.log(this.$route)
    this.getList();
  }
}
</script>
<style>
#big {
  margin: 0 auto;
  height: 800px;
}

#add1 {
  margin-left: 320px;
}

#select1 {
  margin-left: 520px;
}

.block {
  margin-left: 400px
}
#renew{
  margin-left: 70px;
}
</style>

const router = require('koa-router')()
const svgCaptcha = require("svg-captcha")
const user = require('./user.json')
const jwt = require('jsonwebtoken');
const formidable = require("formidable")
const path = require("path")
const mime = require("mime-types")
const fs = require("fs");
const { Console } = require('console');
var verCode = ''



//About.vue


// 获取
router.get("/getnum", async (ctx, next) => {
  let num = []
  let sql = "select * from user1";
  let result = await ctx.db.EXCUTE(sql);
  // console.log(result)
  result.forEach(item => {
    num.push({
      userName: item.userName,
      telephoneNum: item.tel,
      eMail: item.eMail,
      site: item.site,
      timer: item.timer,
      chapterId: item.chapterId
    })
  })
  ctx.body = num;
})

// 查询
router.post("/select",async(ctx,next)=>{
  let text = ctx.request.body.text
  let sql = "select *  from user1 where userName Like '%" + text + "%'" 
  let result = await ctx.db.EXCUTE(sql);
  console.log(result)
  ctx.body = result
})




// Logistics.vue

// 获取
router.get("/getlognum", async (ctx, next) => {
  let logNum = []
  let sql = "select * from logistics ";
  let result = await ctx.db.EXCUTE(sql);
  // console.log(result)
  result.forEach(item => {
    console.log(item.userName)
    logNum.push({
      userName: item.userName,
      tel: item.tel,
      road: item.road,
      site: item.site,
      timer: item.timer,
      chapterId: item.chapterId
    })
  })
  ctx.body = logNum;
})
// 查询
router.post("/selectlog",async(ctx,next)=>{
  let text = ctx.request.body.text
  let sql = "select *  from logistics where userName Like '%" + text + "%'" 
  let result = await ctx.db.EXCUTE(sql);
  console.log(result)
  ctx.body = result
})
module.exports = router

// 置顶
router.post("/movetotop",async(ctx,next)=>{
  let chapterId = ctx.request.body.chapterId
  console.log(ctx.request.body.chapterId)
  let sql = "select *  from logistics1 order by chapterId='" + chapterId +"'DESC" 
  let result = await ctx.db.EXCUTE(sql);
  console.log(result)
  ctx.body=result
})
// 查询
router.post("/select",async(ctx,next)=>{
  let text = ctx.request.body.text
  let sql = "select *  from user where userName Like '%" + text + "%'" 
  let result = await ctx.db.EXCUTE(sql);
  console.log(result)
  ctx.body = result
})















// logistics1.vue

// 获取
router.get("/l1", async (ctx, next) => {
  let logNum = []
  let sql = "select * from logistics1 ";
  let result = await ctx.db.EXCUTE(sql);
  // console.log(result)
  result.forEach(item => {
    console.log(item.userName)
    logNum.push({
      userName: item.userName,
      tel: item.tel,
      road: item.road,
      site: item.site,
      timer: item.timer,
      chapterId: item.chapterId
    })
  })
  ctx.body = logNum;
})

router.post("/selectlog",async(ctx,next)=>{

  // console.log(1)
  // console.log(ctx.request.body)
  // ctx.body="1"
  let text = ctx.request.body.text
  let sql = "select *  from logistics1 where userName Like '%" + text + "%'" 
  let result = await ctx.db.EXCUTE(sql);
  console.log(result)
  ctx.body = result
})


// logistics2.vue

// 获取
router.get("/l2", async (ctx, next) => {
  let logNum = []
  let sql = "select * from logistics2 ";
  let result = await ctx.db.EXCUTE(sql);
  // console.log(result)
  result.forEach(item => {
    console.log(item.userName)
    logNum.push({
      userName: item.userName,
      tel: item.tel,
      road: item.road,
      site: item.site,
      timer: item.timer,
      chapterId: item.chapterId
    })
  })
  ctx.body = logNum;
})

router.post("/selectlog",async(ctx,next)=>{

  // console.log(1)
  // console.log(ctx.request.body)
  // ctx.body="1"
  let text = ctx.request.body.text
  let sql = "select *  from logistics1 where userName Like '%" + text + "%'" 
  let result = await ctx.db.EXCUTE(sql);
  console.log(result)
  ctx.body = result
})








//文本框提交
router.post("/selectlogs",async(ctx,next)=>{
  console.log(ctx.request.body)
 
  ctx.body="1"
})
module.exports = router


<template>
  <div id="big">
    <el-button type="primary" size="mini" @click="showDrawer" id="add">添加数据</el-button>
    <el-input style="width:20%" placeholder="输入路线查询" v-model="text" @input="searchh" id="select"></el-input>
    <el-button type="primary" size="mini" @click="select" id="renew2">查询</el-button>
    <el-button type="primary" size="mini" @click="renew">重置</el-button>
    <el-table
      :data="chapterList.slice((paginations.currentPage - 1) * paginations.PageSize, paginations.currentPage * paginations.PageSize)"
      style="width: 67%; margin: 0 auto;" id="main">
      <el-table-column label="派送线路">
        <template slot-scope="scope">
          
          <span>{{ scope.row.type }}</span>
        </template>
      </el-table-column>
      <el-table-column label="途径">
        <template slot-scope="scope">
          <span>
            {{ scope.row.road }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="地址">
        <template slot-scope="scope">
          <span>
            {{ scope.row.site }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="电话">
        <template slot-scope="scope">
          <span>
            {{ scope.row.tel }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="时间">
        <template slot-scope="scope">
          <span>
            {{ scope.row.timer }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="操作">

        <template slot-scope="scope">
          <el-button size="mini" @click="moveToTop(scope.$index, scope.row)">置顶</el-button>
          <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
          <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-drawer title="我是标题" :visible.sync="drawer" :with-header="false">
      <div style="width: 50%; margin:0 auto; margin-top: 50px">
        <el-input v-model="userName" placeholder="线路名称"></el-input>
      </div>
      <div style="width: 50%; margin:0 auto; margin-top: 50px">
        <el-input v-model="road" placeholder="途径"></el-input>
      </div>
      <div style="width: 50%; margin:0 auto; margin-top: 50px">
        <el-input v-model="site" placeholder="地址"></el-input>
      </div>
      <div style="width: 50%; margin:0 auto; margin-top: 50px">
        <el-input v-model="tel" placeholder="电话"></el-input>
      </div>
      <div style="width: 50%; margin:0 auto; margin-top: 50px">
        <el-date-picker v-model="timer" style="width:95%;" type="date" placeholder="选择日期">
        </el-date-picker>
      </div>
      <div style="margin-top: 30px">
        <el-button type="primary" size="mini" @click="subform" v-show="!this.chapterId">提交</el-button>
        <el-button type="primary" size="mini" @click="subEditForm" v-show="this.chapterId">保存</el-button>
      </div>
    </el-drawer>
    <div class="block">
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
        :current-page="paginations.currentPage" :page-sizes="paginations.pageSizes" :page-size="paginations.PageSize"
        layout="total, sizes, prev, pager, next, jumper" :total="chapterList.length">
      </el-pagination>
    </div>
  </div>
</template>
    
<script>
import axios from 'axios'
export default {
  data() {
    return {
      text: '',
      // searchResult: [],
      chapterList: [],
      drawer: false,
      chapterTitle: "",
      chapterId: "",
      userName: "",
      road: "",
      site: "",
      tel: "",
      timer: "",
      //分页
      paginations: {
        // 默认显示第几页
        currentPage: 1,
        // 个数选择器（可修改）
        pageSizes: [1, 2, 3, 4],
        // 默认每页显示的条数（可修改）
        PageSize: 4,
      },
    }
  },
  // created() {
  //   this.searchResult = this.chapterList //存储
  // },
  methods: {
    //  编辑的提交
    subEditForm() {
      if (localStorage.getItem('token')) {
        axios.post(
          "http://localhost:3000/xiugai",
          {
            
          }
        ).then((res) => {
          if (res.data.code == 200) {
            //success warn danger
            this.drawer = false;
            this.getList();
          }
        })
      } else {
        alert('未登录')
      }

    },
    // 添加数据的提交
    subform() {
      if (localStorage.getItem('token')) {
        axios.post(
          "http://localhost:3000/sublog",
          { userName: this.userName, timer: this.timer, road: this.road, site: this.site, tel: this.tel }
        ).then((res) => {
          if (res.data.code == 200) {
            this.drawer = false;
            this.getList();
          }
        })
      } else {
        alert('未登录')
      }
    },
    // 添加数据的默认内容
    showDrawer() {
      this.drawer = true;
      this.userName = "";
      this.site = "";
      this.tel = "";
      this.road = "";
      this.chapterId = "";
      this.timer = "";
    },
    // 编辑
    handleEdit(index, row) {
      this.drawer = true;
      this.chapterId = row.chapterId;
      this.timer = row.timer;
      this.userName = row.userName;
      this.road = row.road;
      this.site = row.site;
      this.tel = row.tel;
      console.log(row)
    },
    // 删除
    handleDelete(index, row) {
      let chapterId = row.chapterId;
      if (localStorage.getItem('token')) {
        axios.post(
          "http://localhost:3000/dellog",
          { chapterId: chapterId }
        ).then((res) => {
          if (res.data.code == 200) {
            this.chapterList.splice(index, 1);
          }
        })
      } else {
        alert('未登录')
      }
    },
    // 置顶
    moveToTop(index, row) {
      let chapterId = row.chapterId;
      axios.post("http://localhost:3000/movetotop", { chapterId: chapterId }).then(res => {
        let result = res.data;
        this.chapterList = result;
        this.searchResult = this.chapterList
      })
    },
    // 查询
    select() {
      axios.post("http://localhost:3000/selectlog", { text: this.text }).then(res => {
        console.log(res.data)
        let result = res.data;
        this.chapterList = result;
      })
    },
    // 重置
    renew() {
      axios.get("http://localhost:3000/getlognum").then(res => {

      })
    },
    getList() {
      axios.get("http://localhost:3000/getlognum").then(res => {
        let result = res.data;
        this.chapterList = result;
        // this.searchResult = this.chapterList
      })
    },

    // //分页/
    // 每页显示多少条
    handleSizeChange(val) {
      // 改变每页显示的条数 
      this.paginations.PageSize = val
      // 注意：在改变每页显示的条数时，要将页码显示到第一页
      this.paginations.currentPage = 1
      console.log(`每页 ${val} 条`);
    },
    // 现在显示当前页的第几页
    handleCurrentChange(val) {
      // 改变默认的页数
      this.paginations.currentPage = val
      console.log(`当前页: ${val}`);
    },
    // handleOpen(key, keyPath) {
    //   console.log(key, keyPath);
    // },
    // handleClose(key, keyPath) {
    //   console.log(key, keyPath);
    // }

    // searchh: function () {
    //   if (localStorage.getItem('token')) {
    //     this.searchResult = this.chapterList.filter(item => item.userName.includes(this.text))
    //   } else {
    //     alert('未登录')
    //   }
    // }
  },
  mounted() {
    console.log(this.$route)
    this.getList();
  }
}
</script>
<style>
#big {
  margin: 0 auto;
  height: 800px;
}

#add {
  margin-left: 260px;
}

#select {
  margin-left: 600px;
}

.block {
  margin-left: 400px
}
#renew2{
  margin-left: 150px;
}
</style>





<template>
  <div id="big">
    <el-button type="primary" size="mini" @click="showDrawer" id="add">添加数据</el-button>
    <el-input style="width:20%" placeholder="输入路线查询" v-model="text" @input="searchh" id="select"></el-input>
    <el-button type="primary" size="mini" @click="select" id="renew2">查询</el-button>
    <el-button type="primary" size="mini" @click="renew">重置</el-button>
    <el-table
      :data="chapterList.slice((paginations.currentPage - 1) * paginations.PageSize, paginations.currentPage * paginations.PageSize)"
      style="width: 67%; margin: 0 auto;" id="main">
      <el-table-column label="派送线路">
        <template slot-scope="scope">
          
          <span>{{ scope.row.type }}</span>
        </template>
      </el-table-column>
      <el-table-column label="途径">
        <template slot-scope="scope">
          <span>
            {{ scope.row.road }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="地址">
        <template slot-scope="scope">
          <span>
            {{ scope.row.site }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="电话">
        <template slot-scope="scope">
          <span>
            {{ scope.row.tel }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="时间">
        <template slot-scope="scope">
          <span>
            {{ scope.row.timer }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="操作">

        <template slot-scope="scope">
          <el-button size="mini" @click="moveToTop(scope.$index, scope.row)">置顶</el-button>
          <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
          <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-drawer title="我是标题" :visible.sync="drawer" :with-header="false">
      <div style="width: 50%; margin:0 auto; margin-top: 50px">
        <el-input v-model="userName" placeholder="线路名称"></el-input>
      </div>
      <div style="width: 50%; margin:0 auto; margin-top: 50px">
        <el-input v-model="road" placeholder="途径"></el-input>
      </div>
      <div style="width: 50%; margin:0 auto; margin-top: 50px">
        <el-input v-model="site" placeholder="地址"></el-input>
      </div>
      <div style="width: 50%; margin:0 auto; margin-top: 50px">
        <el-input v-model="tel" placeholder="电话"></el-input>
      </div>
      <div style="width: 50%; margin:0 auto; margin-top: 50px">
        <el-date-picker v-model="timer" style="width:95%;" type="date" placeholder="选择日期">
        </el-date-picker>
      </div>
      <div style="margin-top: 30px">
        <el-button type="primary" size="mini" @click="subform" v-show="!this.chapterId">提交</el-button>
        <el-button type="primary" size="mini" @click="subEditForm" v-show="this.chapterId">保存</el-button>
      </div>
    </el-drawer>
    <div class="block">
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
        :current-page="paginations.currentPage" :page-sizes="paginations.pageSizes" :page-size="paginations.PageSize"
        layout="total, sizes, prev, pager, next, jumper" :total="chapterList.length">
      </el-pagination>
    </div>
  </div>
</template>
    
<script>
import axios from 'axios'
export default {
  data() {
    return {
      text: '',
      // searchResult: [],
      chapterList: [],
      drawer: false,
      chapterTitle: "",
      chapterId: "",
      userName: "",
      road: "",
      site: "",
      tel: "",
      timer: "",
      //分页
      paginations: {
        // 默认显示第几页
        currentPage: 1,
        // 个数选择器（可修改）
        pageSizes: [1, 2, 3, 4],
        // 默认每页显示的条数（可修改）
        PageSize: 4,
      },
    }
  },
  // created() {
  //   this.searchResult = this.chapterList //存储
  // },
  methods: {
    //  编辑的提交
    subEditForm() {
      if (localStorage.getItem('token')) {
        axios.post(
          "http://localhost:3000/xiugai",
          {
            
          }
        ).then((res) => {
          if (res.data.code == 200) {
            //success warn danger
            this.drawer = false;
            this.getList();
          }
        })
      } else {
        alert('未登录')
      }

    },
    // 添加数据的提交
    subform() {
      if (localStorage.getItem('token')) {
        axios.post(
          "http://localhost:3000/sublog",
          { userName: this.userName, timer: this.timer, road: this.road, site: this.site, tel: this.tel }
        ).then((res) => {
          if (res.data.code == 200) {
            this.drawer = false;
            this.getList();
          }
        })
      } else {
        alert('未登录')
      }
    },
    // 添加数据的默认内容
    showDrawer() {
      this.drawer = true;
      this.userName = "";
      this.site = "";
      this.tel = "";
      this.road = "";
      this.chapterId = "";
      this.timer = "";
    },
    // 编辑
    handleEdit(index, row) {
      this.drawer = true;
      this.chapterId = row.chapterId;
      this.timer = row.timer;
      this.userName = row.userName;
      this.road = row.road;
      this.site = row.site;
      this.tel = row.tel;
      console.log(row)
    },
    // 删除
    handleDelete(index, row) {
      let chapterId = row.chapterId;
      if (localStorage.getItem('token')) {
        axios.post(
          "http://localhost:3000/dellog",
          { chapterId: chapterId }
        ).then((res) => {
          if (res.data.code == 200) {
            this.chapterList.splice(index, 1);
          }
        })
      } else {
        alert('未登录')
      }
    },
    // 置顶
    moveToTop(index, row) {
      let chapterId = row.chapterId;
      axios.post("http://localhost:3000/movetotop", { chapterId: chapterId }).then(res => {
        let result = res.data;
        this.chapterList = result;
        this.searchResult = this.chapterList
      })
    },
    // 查询
    select() {
      axios.post("http://localhost:3000/selectlog", { text: this.text }).then(res => {
        console.log(res.data)
        let result = res.data;
        this.chapterList = result;
      })
    },
    // 重置
    renew() {
      axios.get("http://localhost:3000/getlognum").then(res => {

      })
    },
    getList() {
      axios.get("http://localhost:3000/getlognum").then(res => {
        let result = res.data;
        this.chapterList = result;
        // this.searchResult = this.chapterList
      })
    },

    // //分页/
    // 每页显示多少条
    handleSizeChange(val) {
      // 改变每页显示的条数 
      this.paginations.PageSize = val
      // 注意：在改变每页显示的条数时，要将页码显示到第一页
      this.paginations.currentPage = 1
      console.log(`每页 ${val} 条`);
    },
    // 现在显示当前页的第几页
    handleCurrentChange(val) {
      // 改变默认的页数
      this.paginations.currentPage = val
      console.log(`当前页: ${val}`);
    },
    // handleOpen(key, keyPath) {
    //   console.log(key, keyPath);
    // },
    // handleClose(key, keyPath) {
    //   console.log(key, keyPath);
    // }

    // searchh: function () {
    //   if (localStorage.getItem('token')) {
    //     this.searchResult = this.chapterList.filter(item => item.userName.includes(this.text))
    //   } else {
    //     alert('未登录')
    //   }
    // }
  },
  mounted() {
    console.log(this.$route)
    this.getList();
  }
}
</script>
<style>
#big {
  margin: 0 auto;
  height: 800px;
}

#add {
  margin-left: 260px;
}

#select {
  margin-left: 600px;
}

.block {
  margin-left: 400px
}
#renew2{
  margin-left: 150px;
}
</style>






<template>
  <div id="big">
    <el-button type="primary" size="mini" @click="showDrawer" id="add1">添加数据</el-button>
    <el-input style="width:20%" placeholder="输入用户名查询" v-model="text" id="select1"></el-input>
    <el-button type="primary" size="mini" @click="select" id="renew">查询</el-button>
    <el-button type="primary" size="mini" @click="renew" >重置</el-button>
    <el-table
      :data="chapterList.slice((paginations.currentPage - 1) * paginations.PageSize, paginations.currentPage * paginations.PageSize)"
      style="width: 60%; margin: 0 auto;" id="main">
      <el-table-column label="姓名">
        <template slot-scope="scope">
          <i class="el-icon-time"></i>
          <span style="margin-left: 10px">{{ scope.row.userName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="电话">
        <template slot-scope="scope">
          <span>
            {{ scope.row.telephoneNum }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="邮箱">
        <template slot-scope="scope">
          <span>
            {{ scope.row.eMail }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="地址">
        <template slot-scope="scope">
          <span>
            {{ scope.row.site }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
          <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-drawer title="我是标题" :visible.sync="drawer" :with-header="false">
      <div style="width: 50%; margin:0 auto; margin-top: 50px">
        <el-input v-model="userName" placeholder="姓名"></el-input>
      </div>
      <div style="width: 50%; margin:0 auto; margin-top: 50px">
        <el-input v-model="telephoneNum" placeholder="电话"></el-input>
      </div>
      <div style="width: 50%; margin:0 auto; margin-top: 50px">
        <el-input v-model="eMail" placeholder="邮箱"></el-input>
      </div>
      <div style="width: 50%; margin:0 auto; margin-top: 50px">
        <el-input v-model="site" placeholder="地址"></el-input>
      </div>
      <div style="width: 50%; margin:0 auto; margin-top: 50px">
        <el-date-picker v-model="timer" style="width:95%;" type="date" placeholder="选择日期">
        </el-date-picker>
      </div>
      <div style="margin-top: 30px">
        <el-button type="primary" size="mini" @click="subform" v-show="!this.chapterId">提交</el-button>
        <el-button type="primary" size="mini" @click="subEditForm" v-show="this.chapterId">保存</el-button>
      </div>
    </el-drawer>
    <div class="block">
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
        :current-page="paginations.currentPage" :page-sizes="paginations.pageSizes" :page-size="paginations.PageSize"
        layout="total, sizes, prev, pager, next, jumper" :total="chapterList.length">
      </el-pagination>
    </div>
  </div>
</template>
  
<script>
import axios from 'axios'
export default {
  data() {
    return {
      text: '',
      // searchResult: [],
      chapterList: [],
      drawer: false,
      chapterTitle: "",
      chapterId: "",
      userName: "",
      telephoneNum: "",
      eMail: "",
      site: "",
      timer: "",
      //分页
      paginations: {
        // 默认显示第几页
        currentPage: 1,
        // 个数选择器（可修改）
        pageSizes: [1, 2, 3, 4],
        // 默认每页显示的条数（可修改）
        PageSize: 4,
      },
    }
  },
  // watch:{
  //   'text':(newV,oldV)=>{
  //     if(newV == ''){
  //       axios.get("http://localhost:3000/getnum").then(res => {
  //       let result = res.data;
  //       console.log(result)
  //       // this.chapterList = result;
  //       // this.searchResult = this.chapterList
  //     })
  //     }
  //   }
  // },
  // created() {
  //   this.searchResult = this.chapterList //存储
  // },
  methods: {
    //  编辑的提交
    subEditForm() {
      if (localStorage.getItem('token')) {
        axios.post(
          "http://localhost:3000/subeditform",
          {
            chapterId: this.chapterId,
            userName: this.userName,
            telephoneNum: this.telephoneNum,
            eMail: this.eMail,
            site: this.site,
            timer: this.timer
          }
        ).then((res) => {
          if (res.data.code == 200) {
            //success warn danger
            this.drawer = false;
            this.getList();
          }
        })
      } else {
        alert('未登录')
      }
    },
    // 添加数据的提交
    subform() {
      if (localStorage.getItem('token')) {
        axios.post(
          "http://localhost:3000/subform",
          { userName: this.userName, timer: this.timer, telephoneNum: this.telephoneNum, eMail: this.eMail, site: this.site }
        ).then((res) => {
          if (res.data.code == 200) {
            this.drawer = false;
            this.getList();
          }
        })
      } else {
        alert('未登录')
      }
    },
    // 添加数据的默认内容
    showDrawer() {
      this.drawer = true;
      this.userName = "";
      this.eMail = "";
      this.site = "";
      this.telephoneNum = "";
      this.chapterId = "";
      this.timer = "";
    },
    // 编辑
    handleEdit(index, row) {
      this.drawer = true;
      this.chapterId = row.chapterId;
      this.timer = row.timer;
      this.userName = row.userName;
      this.telephoneNum = row.telephoneNum;
      this.eMail = row.eMail;
      this.site = row.site;
      console.log(row)
    },
    // 删除
    handleDelete(index, row) {
      let chapterId = row.chapterId;
      if (localStorage.getItem('token')) {
        axios.post(
          "http://localhost:3000/delchapter",
          { chapterId: chapterId }
        ).then((res) => {
          if (res.data.code == 200) {
            this.getList();
          }
        })
      } else {
        alert('未登录')
      }
    },
    // 查询
    select() {
      axios.post("http://localhost:3000/select", { text: this.text }).then(res => {
        console.log(res.data)
        let result = res.data;
        this.chapterList = result;
      })
    },
    // 重置
    renew(){
      axios.get("http://localhost:3000/getnum").then(res => {
        let result = res.data;
        this.chapterList = result;
        this.text = ''
      })
    },
    //获取
    getList() {
      axios.get("http://localhost:3000/getnum").then(res => {
        let result = res.data;
        this.chapterList = result;
        // this.searchResult = this.chapterList
      })
    },
    // //分页/
    // 每页显示多少条
    handleSizeChange(val) {
      // 改变每页显示的条数 
      this.paginations.PageSize = val
      // 注意：在改变每页显示的条数时，要将页码显示到第一页
      this.paginations.currentPage = 1
      console.log(`每页 ${val} 条`);
    },
    // 现在显示当前页的第几页
    handleCurrentChange(val) {
      // 改变默认的页数
      this.paginations.currentPage = val
      console.log(`当前页: ${val}`);
    },
    // handleOpen(key, keyPath) {
    //   console.log(key, keyPath);
    // },
    // handleClose(key, keyPath) {
    //   console.log(key, keyPath);
    // }

    // searchh: function () {
    //   if (localStorage.getItem('token')) {
    //     this.searchResult = this.chapterList.filter(item => item.userName.includes(this.text))
    //   } else {
    //     alert('未登录')
    //   }
    // }
  },
  mounted() {
    console.log(this.$route)
    this.getList();
  }
}
</script>
<style>
#big {
  margin: 0 auto;
  height: 800px;
}

#add1 {
  margin-left: 320px;
}

#select1 {
  margin-left: 520px;
}

.block {
  margin-left: 400px
}
#renew{
  margin-left: 70px;
}
</style>